﻿using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;

public class ZDebugTools : EditorWindow
{
    public bool isDeletePlayerPrefs = false;
    public bool isDeleteDataFile = false;
    [MenuItem("Debug/ZDebugTools")]
    public static void ShowWindow()
    {
        ZDebugTools window = GetWindow<ZDebugTools>("调试工具");

    }
    private void OnGUI()
    {
        isDeletePlayerPrefs = EditorGUILayout.Toggle("删除PlayerPrefs数据", isDeletePlayerPrefs);
        isDeleteDataFile = EditorGUILayout.Toggle("删除用户文件数据数据", isDeleteDataFile);
        if (GUILayout.Button("确认删除"))
        {
            DelectData();
        }
    }
    void DelectData()
    {
        if (isDeletePlayerPrefs)
        {
            PlayerPrefs.DeleteAll();
        }
        if (isDeleteDataFile)
        {
            string persistentDataPath = Application.persistentDataPath;
            if (Directory.Exists(persistentDataPath))
            {
                string[] files = Directory.GetFiles(persistentDataPath);
                foreach (string file in files)
                {
                    File.Delete(file);
                    Debug.Log($"Deleted: {file}");
                }
            }
        }
        isDeletePlayerPrefs = false;
        isDeleteDataFile = false;
    }

    // Update is called once per frame
    void Update()
    {

    }
}
